using Godot;
using System;

public partial class Grass : Node2D
{

	private Hurtbox hurtbox;

	[Export]
	private PackedScene GRASS_EFFECT;

	public override void _Ready()
	{
		hurtbox = GetNode<Hurtbox>("Hurtbox");

		hurtbox.Hurt += OnAreaEntered;

	}

	private void OnAreaEntered(Hitbox otherHitbox) {
		AnimatedSprite2D grass_effect = GRASS_EFFECT.Instantiate<AnimatedSprite2D>();
		grass_effect.GlobalPosition = GlobalPosition;
		GetTree().CurrentScene.AddChild(grass_effect);
		QueueFree();
	}
}
